﻿@using Partner.Surround.Web.Startup
@using Partner.Surround.Authorization
@{
    ViewBag.CurrentPageName = PageNames.AuditLogs;
    var startDate = DateTime.Now.AddDays(-6).ToString("yyyy-MM-dd");
    var endDate = DateTime.Now.AddDays(+1).ToString("yyyy-MM-dd");
}

@section styles{
    <style>
        .layui-card-header.layui-card-header-auto {
            padding-top: 15px;
            padding-bottom: 5px;
            height: auto;
        }
    </style>
}

<!--审计日志列表-->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-header layui-card-header-auto">
            <div class="layui-form">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">控制器名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="serviceName" placeholder="请输入控制器名称" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">开始日期</label>
                        <div class="layui-input-block">
                            <input type="text" name="startDate" id="startDate" lay-verify="date" placeholder="请选择开始日期" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">截止日期</label>
                        <div class="layui-input-block">
                            <input type="text" name="endDate" id="endDate" lay-verify="date" placeholder="请选择截止日期" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button class="layui-btn layui-btn-user" lay-submit lay-filter="LAY-auditlog-front-search">
                            <i class="layui-icon layui-icon-search layui-button-btn"></i>
                        </button>
                    </div>
                </div>
            </div>
        </div>

        <div class="layui-card-body">
            <div class="layui-row">
                <div class="layui-col-xs12">
                    <table class="layui-table"
                           lay-data="{height: 'full-145', page:true, id:'auditLogList'}"
                           lay-filter="auditLogList">
                        <thead>
                            <tr>
                                <th lay-data="{field:'id', width:'10%'}">ID</th>
                                <th lay-data="{field:'serviceName', width:'20%',sort: true}">控制器</th>
                                <th lay-data="{field:'methodName', width:'20%', sort: true}">方法</th>
                                <th lay-data="{field:'parameters', width:'25%'}">参数</th>
                                <th lay-data="{field:'executionTime',templet:'#executionTime',width:'15%'}">执行时间</th>
                                <th lay-data="{field:'executionDuration',width:'10%',}">执行耗时</th>
                            </tr>
                        </thead>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>

<!--执行时间-->
<script type="text/html" id="executionTime">
    {{layui.util.toDateString(d.executionTime, 'yyyy-MM-dd HH:mm:ss')}}
</script>

@section scripts{
    <script type="text/javascript">
        layui.config({
            base: '/lib/layui-extend-modules/' //静态资源所在路径
        }).use(['jquery','laydate','form', 'layer', 'table'], function () {
            var $ = layui.$,
                laydate = layui.laydate,
                form = layui.form;
                table = layui.table;

            //开始日期
            laydate.render({
                elem: '#startDate',
                value: '@startDate'
            });

            //截止日期
            laydate.render({
                elem: '#endDate',
                value: '@endDate'
            });
            form.render();

            //监听搜索
            form.on('submit(LAY-auditlog-front-search)', function (data) {
                var field = data.field;

                mainList(field);//执行重载
            });

            //主列表加载，可反复调用进行刷新
            var config = {};  //table的参数，如搜索key，点击tree的id
            var auditLogList = function (options) {
                if (options != undefined) {
                    $.extend(config, options);
                }
                table.reload('auditLogList', {
                    url: "@Url.Action("GetAuditLogList", "AuditLogs")",
                    where: config,
                    parseData: function (res) {
                        return {
                            "code": res.result.code, //解析接口状态
                            "msg": res.result.msg, //解析提示文本
                            "count": res.result.count, //解析数据长度
                            "data": res.result.data //解析数据列表
                        };
                    },
                    response: {
                        statusCode: 200 //规定成功的状态码，默认：0
                    }
                });
            };
            auditLogList({"startDate":"@startDate","endDate":"@endDate"});
        });
    </script>
}

